<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "complaints_img".
 *
 * @property int $id
 * @property int $complaint_id
 * @property int $image_id
 *
 * @property Complaints $complaint
 * @property Image $image
 */
class ComplaintsImg extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'complaints_img';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['complaint_id', 'image_id'], 'integer'],
            [
                ['complaint_id'],
                'exist',
                'skipOnError'     => true,
                'targetClass'     => Complaints::className(),
                'targetAttribute' => ['complaint_id' => 'id']
            ],
            [
                ['image_id'],
                'exist',
                'skipOnError'     => true,
                'targetClass'     => Image::className(),
                'targetAttribute' => ['image_id' => 'id']
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id'           => 'ID',
            'complaint_id' => 'Complaint ID',
            'image_id'     => 'Image ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getComplaint()
    {
        return $this->hasOne(Complaints::className(), ['id' => 'complaint_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getImage()
    {
        return $this->hasOne(Image::className(), ['id' => 'image_id']);
    }


}
